package com.amoby.main.schedule;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.amoby.main.service.AlipayOrderTransferService;

@Component
public class AlipayOrderTransferTask {
    private static final Logger        logger = LoggerFactory.getLogger(AlipayOrderTransferTask.class);
    @Autowired
    private AlipayOrderTransferService alipayOrderTransferService;

    
    /**
     * 支付宝活动每天0点检查商户是否满足后台配置的转账金额
     * @author Lasing 2016-2-18 下午4:40:57
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void alipayTransfer() {
        try {
            /** 查询当前未转账的商家 */
            alipayOrderTransferService.alipayTransfer();
        } catch (Exception e) {
            logger.error("支付宝活动订商家0点转账任务失败", e);
        }
    }
    /**
     * 批量转账
     */
    /*@Scheduled(cron = "0 0 0 * * ?")
    public void alipayTransferBatch() {
        try {
            *//** 查询当前未转账的商家 *//*
            alipayOrderTransferService.alipayTransferBatch();
        } catch (Exception e) {
            logger.error("支付宝活动订商家0点转账任务失败", e);
        }
    }*/
    
    
    
    /**
     * 渠道批量转账
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void alipayTransferChannelBatch() {
        try {
            /** 查询当前未转账的渠道 */
            alipayOrderTransferService.alipayTransferChannelBatch();
        } catch (Exception e) {
            logger.error("支付宝活动订商家0点转账任务失败", e);
        }
    }
    
    /**
     * 每月8号1点支付宝活动订单向商家转账
     * @author Lasing 2016-2-18 下午5:42:28
     */
    @Scheduled(cron = "0 0 1 8 * ?")
    public void alipay8Transfer() {
        try {
            /** 查询当前未转账的商家 */
            alipayOrderTransferService.alipay8Transfer();
        } catch (Exception e) {
            logger.error("支付宝活动订商家1点转账任务失败", e);
        }
    }
    
    /**
     * 每月8号1点支付宝活动订单向商家转账
     * @author Lasing 2016-2-18 下午5:42:28
     */
    /*@Scheduled(cron = "0 0 1 8 * ?")
    public void alipay8TransferBatch() {
        try {
            *//** 查询当前未转账的商家 *//*
            alipayOrderTransferService.alipay8TransferBatch();
        } catch (Exception e) {
            logger.error("支付宝活动订商家1点转账任务失败", e);
        }
    }*/
    
    /**
     * 每月8号1点支付宝活动订单批量向商家转账
     * @author Lasing 2016-2-18 下午5:42:28
     */
    @Scheduled(cron = "0 0 1 8 * ?")
    public void alipay8TransferChannelBatch() {
        try {
            /** 查询当前未转账的商家 */
            alipayOrderTransferService.alipay8TransferChannelBatch();
        } catch (Exception e) {
            logger.error("支付宝活动订商家1点转账任务失败", e);
        }
    }
}
